﻿/*********************************************************************
 * Módulo 3. Tutorial de desarrollo con NME. Bucle de juego
 * Programación Multimedia y Juegos
 * Autor: David Vallejo Fernández    david.vallejo@tegnix.com
 * Autor: Carlos González Morcillo   carlos.gonzalez@tegnix.com
 *
 * You can redistribute and/or modify this file under the terms of the
 * GNU General Public License ad published by the Free Software
 * Foundation, either version 3 of the License, or (at your option)
 * and later version. See <http://www.gnu.org/licenses/>.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.  
 *********************************************************************/

package;

import flash.display.Sprite;
import flash.Lib;

class BubbleDemo extends Sprite {

  public static var _instance:BubbleDemo;

  private function new () {		
    super ();

    // Recuperación de singletons.
    var gameManager:GameManager = GameManager.getInstance();
    var introState:GameState = IntroState.getInstance();
    var playState:GameState = PlayState.getInstance();
    var pauseState:GameState = PauseState.getInstance();
    var gameOverState:GameState = GameOverState.getInstance();
    

    // Hijos de BubbleDemo.
    addChild(introState);
    addChild(playState);
    addChild(pauseState);
    addChild(gameOverState);

    // Arranque del juego con el estado inicial.
    gameManager.start(introState);
  }

  // Patrón Singleton.
  public static function getInstance() : BubbleDemo {
    if (BubbleDemo._instance == null)
      BubbleDemo._instance = new BubbleDemo();
    return BubbleDemo._instance;
  }

  public static function main () {		
    Lib.current.addChild (BubbleDemo.getInstance ());
  }
		
}
